package com.dyz.LeetCodeforSwordFingerOffer;

public class PrintNumbers17 {
    public int[] printNumbers(int n) {
        if (n <= 0) {
            return new int[]{};
        }
        //先求 10的n次方的减1的范围，在遍历添加
        int numbers = power(10, n) - 1;
        int[] list = new int[numbers];
        for (int i = 1; i <= numbers; i++) {
            list[i - 1] = i;
        }
        return list;
    }

    public static int power(int val, int n) {
        int power = 1;
        for (int c = 0; c < n; c++)
            power *= val;
        return power;

    }
}

